const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2020${i}`,
            code: `2020${i}`,
            dealerCode: `dealerCode${i}`,
            countryOfOrigin: '中国',
            countryOfDestination: '美国',
            brandCode: `brandCode${i}`,
            deliveryTerms: 1,
            tradeMethodName: `贸易方式${i}`,
            salesOrderPriceTerms: 1,
            paymentType: 1,
            carrierCode: `carrierCode${i}`,
            carrierName: 'carrierName',
            totalAmount: 20205012,
            productAmount: 213123,
            shipmentAmount: 12314,
            insuranceAmount: 21312,
            currency: 1,
            createTime: '2020-02-17T06:05:12.351Z',
            confirmTime: '2020-02-17T06:05:12.351Z',
            status: 1,
            dataSource: 2,
            batchNumber: '132',
            marketDepartmentName: 'marketDepartmentName1',
            country: 'country',
            rowVersion: 'string',
            options: ['update', 'abandon', 'confirm', 'cancel', 'exportExcel', 'exportPdf']
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});
router.get('/forCBUSaleOrder', (req, res) => {
    const content = [];
    for(let i = 0; i < 5; i++)
        content.push({
            id: `2020${i}`,
            piCode: `2020${i}`,
            country: 'string',
            paymentType: 1,
            tradeMethodName: 'string',
            currency: 1,
            salesOrderPriceTerms: 1,
            transportType: 1,
            details: [
                {
                    id: `2020${i}1`,
                    productGroupCode: 'string',
                    productGroupName: 'string',
                    quantity: 0
                }, {
                    id: `2020${i}2`,
                    productGroupCode: 'string',
                    productGroupName: 'string',
                    quantity: 0
                }, {
                    id: `2020${i}3`,
                    productGroupCode: 'string',
                    productGroupName: 'string',
                    quantity: 0
                }]
        });
    for(let i = 5; i < 10; i++)
        content.push({
            id: `2020${i}`,
            piCode: `2020${i}`,
            country: 'string',
            paymentType: 1,
            tradeMethodName: 'string',
            currency: 1,
            salesOrderPriceTerms: 2,
            transportType: 2,
            details: [
                {
                    id: `2020${i}1`,
                    productGroupCode: 'string',
                    productGroupName: 'string',
                    quantity: 0
                }, {
                    id: `2020${i}2`,
                    productGroupCode: 'string',
                    productGroupName: 'string',
                    quantity: 0
                }, {
                    id: `2020${i}3`,
                    productGroupCode: 'string',
                    productGroupName: 'string',
                    quantity: 0
                }]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});

router.get('/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '20191',
                code: '20191',
                brandId: '65465',
                brandCode: 'brandCode',
                brandName: 'brandName',
                dealerId: '56465',
                dealerCode: 'dealerCode',
                countryOfOrigin: 'countryOfOrigin',
                countryOfDestination: 'countryOfDestination',
                address: 'address',
                contactNumber: 'contactNumber',
                zipCode: 'zipCode',
                cNPJ: 'cNPJ',
                contact: 'contact',
                tELEX: 'tELEX',
                currency: 1,
                tradeMethodId: '456',
                tradeMethodName: 'tradeMethodName',
                salesOrderPriceTerms: 3,
                paymentType: 1,
                shipmentAmount: 1235,
                insuranceAmount: 2131,
                productAmount: 546546,
                taxRate: 0.25,
                totalAmount: 3541534,
                deliveryTerms: 1,
                payableAccount: 'payableAccount',
                carrierId: '546',
                carrierName: 'carrierName',
                shippingPortId: '546',
                shippingPortName: 'shippingPortName',
                destinationPort: 'destinationPort',
                createTime: '2020-02-17T08:24:39.398Z',
                creator: 'creator',
                commodity: 'commodity',
                confirmor: 'confirmor',
                confirmTime: '2020-02-17T08:25:12.893Z',
                confirmIdea: 'confirmIdea',
                remark: 'remark',
                bankId: '12312',
                bankAccount: 'bankAccount',
                bankName: 'bankName',
                bankNameEng: 'bankNameEng',
                bankAddress: 'bankAddress',
                dataSource: 3,
                sWIFT: 'sWIFT',
                batchNumber: 'batchNumber',
                buyer: 'buyer',
                marketDepartmentName: 'marketDepartmentName',
                country: '中国',
                certificationAmount: 12341.12,
                ifUseBatchNumberToPrint: true,
                estimatedDeliveryDate: '2020-05-13T06:22:13.458Z',
                validity: '2020-05-13T06:22:13.458Z',
                packing: 'afffdasfsd',
                attachments: [
                    {
                        fileId: '001',
                        fileName: 'fileName001'
                    }
                ],
                rowVersion: 'string',
                options: ['update', 'abandon', 'confirm', 'cancel', 'exportExcel', 'exportPdf'],
                saleProformaInvoiceDetails: [
                    {
                        id: '001',
                        sourceCode: 'sourceCode',
                        productGroupCode: 'productGroupCode',
                        productGroupName: 'productGroupName',
                        productGroupId: 'productGroupId',
                        productCategoryId: 'productCategoryId',
                        productCategoryCode: 'productCategoryCode',
                        productCategoryName: 'productCategoryName',
                        quantity: 12,
                        price: 12305,
                        totalPrice: 5464515,
                        taxFreePrice: 123,
                        taxFreeTotalPrice: 45665,
                        dataSource: 2,
                        kDBomCode: 'kDBomCode1',
                        descriptionOfGoods: 'descriptionOfGoods1',
                        laborHour: 12,
                        laborPrice: 123465,
                        taxFreeLaborPrice: 100000,
                        remark: 'remark1',
                        unitShipmentAmount: 20,
                        unitInsuranceAmount: 22,
                        versionCode: 'versionCode001',
                        versionName: 'versionName001',
                        shipmentAmountSum: 13125,
                        insuranceAmountSum: 15404,
                        amountSum: 123143,
                        volumeSum: 213.32,
                        unitVolume: 13413.44,
                        productCode: 'productCode1',
                        color: 'red'
                    },
                    {
                        id: '002',
                        sourceCode: 'sourceCode',
                        productGroupCode: 'productGroupCode',
                        productGroupName: 'productGroupName',
                        productGroupId: 'productGroupId',
                        productCategoryId: 'productCategoryId',
                        productCategoryCode: 'productCategoryCode',
                        productCategoryName: 'productCategoryName',
                        quantity: 12,
                        price: 12305,
                        totalPrice: 5464515,
                        taxFreePrice: 123,
                        taxFreeTotalPrice: 45665,
                        dataSource: 2,
                        kDBomCode: 'kDBomCode2',
                        descriptionOfGoods: 'descriptionOfGoods2',
                        laborHour: 12,
                        laborPrice: 123465,
                        taxFreeLaborPrice: 100000,
                        remark: 'remark2',
                        unitShipmentAmount: 20,
                        unitInsuranceAmount: 22,
                        versionCode: 'versionCode001',
                        versionName: 'versionName001',
                        shipmentAmountSum: 13125,
                        insuranceAmountSum: 15404,
                        amountSum: 123143,
                        volumeSum: 213.32,
                        unitVolume: 13432.21,
                        productCode: 'productCode2',
                        color: 'yellow'
                    }
                ],
                saleProformaPartDetails: [{
                    id: '001',
                    partCode: 'partCode001',
                    partName: 'partName001',
                    quantity: 12,
                    price: 12.12
                }]
            }
        }
    );
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.put('/:id/confirm', (req, res) => {
    res.json({
        message: '确认成功'
    });
});

router.put('/:id/confirmPi', (req, res) => {
    res.json({
        message: '发票确认成功'
    });
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.put('/:id/cancel', (req, res) => {
    res.json({
        message: '取消成功'
    });
});

module.exports = router;
